Federated query engine for federation of data queries across structure and unstructured data

ABSTRACT

The subject technology provides querying structured and unstructured data across disparate incompatible systems with a single language and connection point. Cost based optimizations are provided for executing the query. In some configurations, logical plans for executing a query are generated. For each of the logical plans, the subject technology generates a set of physical plans for executing the query on data systems, determines an execution cost for each physical plan from the physical plans, and selects a respective physical plan with a lowest determined execution cost among the determined execution cost for each physical plan. A physical plan is then selected for execution with a lowest execution cost among the selected respective physical plans of each of the logical plans. Data from an operation from the query may then be persisted and then used for generating a new set of logical and physical plans for executing a remaining set of operations from the query.

CROSS-REFERENCE TO RELATED APPLICATIONS

The present application claims the benefit of priority under 35 U.S.C.§119 from U.S. Provisional Patent Application Ser. No. 61/541,036entitled “FEDERATED QUERY ENGINE FOR FEDERATION OF DATA QUERIES ACROSSSTRUCTURE AND UNSTRUCTURED DATA,” filed on Sep. 29, 2011, and U.S.Provisional Patent Application Ser. No. 61/661,737 entitled, “FEDERATEDQUERY ENGINE FOR FEDERATION OF DATA QUERIES ACROSS STRUCTURED ANDUNSTRUCTURED DATA,” filed on Jun. 19, 2012, the disclosures of which arehereby incorporated by reference in its entirety for all purposes.

BACKGROUND

Data systems contain a variety of data query and storage engines from avariety of manufacturers. Each engine has certain advantages anddisadvantages for its use, as well as different versions of data accesslanguages such as SQL (Structured Query Language). All these differencespresent a complex problem for users who want to extract value from thedata regardless of where the elements of data may exist. For instance,those users make multiple connections, use multiple tools, and possess avariety of skills to enable access to data as a whole.

SUMMARY

The subject technology provides for receiving a query for data storedacross a plurality of data systems. The subject technology provides forgenerating a plurality of logical plans for executing the query. Thesubject technology generates a plurality of logical plans for executinga query. For each of the plurality of logical plans, the subjecttechnology generates a first set of physical plans for executing thequery on the plurality of data systems based on the respective logicalplan, determines an execution cost for each physical plan from the firstset of physical plans, and selects the physical plan with a lowestdetermined execution cost from the first set of physical plans. Aphysical plan is then selected with a lowest execution cost among theselected respective physical plans of each of the logical plans. A firstoperation from the query is then executed according to the selectedphysical plan among the selected respective physical plans of each ofthe logical plans. The subject technology updates the query based onresults from the executed first operation from the query, generates asecond plurality of logical plans for executing a new query for aremaining set of operations from the query based on the results andrespective physical plans for each of the second plurality of logicalplans, and selects a physical plan with a lowest execution cost amongthe respective physical plans for each of the second plurality oflogical plans. A second operation is then executed from the new queryaccording to the selected physical plan. The new query is then updatedbased on results from the executed second operation from the new query.For a second new query based on a remaining set of operations from thenew query, the subject technology repeats steps for generating logicalplans, selecting a physical plan, executing an operation among thesecond remaining set of operations, and updating the second new queryuntil the second new query is complete.

The subject technology further includes a system. The system includesmemory, one or more processors, one or more modules stored in memory andconfigured for execution by the one or more processors. The systemincludes a protocol module configured to receive a query. The systemincludes a parser module configured to receive the query from theprotocol module, validate a syntax of the received query, convert thequery into a query tree if the syntax is validated, and identify eachdata element referenced in the query tree. Additionally, the systemincludes a binder module configured to configured to add metadata foreach data element referenced by the query tree. The system also includesan optimizer module configured to determine one or more physicalexecution plans based on the query tree, estimate a cost for each of thephysical execution plans based on the metadata for each data elementreferenced by the query tree, and select a respective physical executionplan with an overall lowest estimated cost. Further, the system includesan execution engine module configured to execute an operation from thequery based on the selected respective physical execution plan, andpersist data resulting from the executed operation from the query.

Additionally, the subject technology provides for receiving a query fordata stored across a plurality of data systems, generating a pluralityof logical plans for executing the query and a respective plurality ofphysical plans for executing each of the plurality of logical plans, anddetermining an execution cost for each of the physical plans. Anoperation from the physical plan having the lowest execution cost isthen executed, and the query is updated based on results from theexecuted operation. Further, the subject technology repeats thegenerating, determining, executing, and updated steps until the query iscomplete.

It is understood that other configurations of the subject technologywill become readily apparent from the following detailed description,where various configurations of the subject technology are shown anddescribed by way of illustration. As will be realized, the subjecttechnology is capable of other and different configurations and itsseveral details are capable of modification in various other respects,all without departing from the scope of the subject technology.Accordingly, the drawings and detailed description are to be regarded asillustrative in nature and not as restrictive.

BRIEF DESCRIPTION OF THE DRAWINGS

The features of the subject technology are set forth in the appendedclaims. However, for purpose of explanation, several configurations ofthe subject technology are set forth in the following figures.

FIG. 1 illustrates an example computing environment for federation ofdata queries across one or more computing systems according to someconfigurations of the subject technology.

FIG. 2 conceptually illustrates a high level architectural layout of asystem that implements a federated query engine according to someconfigurations of the subject technology

FIG. 3 conceptually illustrates an example process for executing severaloperations of a query according to a cost determination of a set ofexecution plans for the query.

FIG. 4A conceptually illustrates example query trees for a queryaccording to some configurations of the subject technology.

FIGS. 4B-1 and 4B-2 conceptually illustrate an example set ofalternative physical plans for a first query tree.

FIGS. 4C-1 and 4C-2 conceptually illustrate an example set ofalternative physical plans for a second query tree.

FIG. 5 conceptually illustrates an example process for optimization,re-optimization and execution according to some configurations of thesubject technology.

FIG. 6 conceptually illustrates a system with which some implementationsof the subject technology may be implemented.

DETAILED DESCRIPTION

The detailed description set forth below is intended as a description ofvarious configurations of the subject technology and is not intended torepresent the only configurations in which the subject technology may bepracticed. The appended drawings are incorporated herein and constitutea part of the detailed description. The detailed description includesspecific details for the purpose of providing a thorough understandingof the subject technology. However, the subject technology is notlimited to the specific details set forth herein and may be practicedwithout these specific details. In some instances, structures andcomponents are shown in block diagram form in order to avoid obscuringthe concepts of the subject technology.

Some approaches to handle a heterogeneous computing environment foraccessing data across disparate systems may resolve only a part of theproblem of accessing these types of widely spread and different datastores. Performance, ease of use, manageability, interoperability, costof ownership, and other concerns should be addressed to resolve thiscomplicated problem in an effective manner.

Adding to all of this difficulty is the emergence and acceptance of newunstructured data stores such as HADOOP, a software framework thatsupports data-intensive distributed applications, which operate totallydifferently from structured data stores. Allowing federation over theseengines in addition to structured stores is a much more complex problemrequiring a new approach to federation. Although the emergence of theseunstructured data stores increases the need for federation to allowmelding of data from both structured and unstructured stores, itincreases complexity of doing so dramatically.

A related significant hindrance to using unstructured data such asHADOOP provides within map-reduce is the need to do programming forspecific functionality. This increases the skill level requireddramatically and prevents common business users from extracting valuefrom unstructured data. The melding of data from structured andunstructured stores is also difficult and complex, requiring yet anotherskill set. All of these requirements hinder the adoption of the use ofunstructured data significantly and greatly complicate the combined useof data as a whole.

In some configurations, the subject technology advantageously fills theaforementioned deficiencies by providing a system including a federatedquery engine that advantageously allows for automatic querying of bothstructured and unstructured data alike from multiple data engines andstores without prior configuration and with optimal performance. In thismanner, the herein described federated query engine provides access toany and all data stores with a single language and access point.

One objective of the subject technology is to abstract the physicalstorage of the data from the logical use of that data. This objectivecan be accomplished in one or more of the following ways: providing asingle connection point to query data in multiple engines using a singletool and single language; invisibly managing the movement of databetween the engines that partake in the query execution; providingaccess to unstructured data in the same syntactical manner as structureddata; and providing the ability to process data within a structured oran unstructured engine in equivalent functionality.

Another objective of the subject technology is to provide fastperformance without the user needing to understand the details of costfor each operation on various systems. This objective may beaccomplished by costing both structured and unstructured data operationsacross multiple data engines in a normalized fashion, taking intoaccount data movement costs, then providing periodic re-optimization toensure that the best plan is chosen as information becomes more precise.

Another objective of the subject technology is to produce metadata andcost metrics for completed operations from queries that can be usedsubsequently to produce performance predictions and improve on costanalysis in future executions. This allows the herein described systemto improve in predictive accuracy through time. Yet another objective ofthe subject technology is to provide a solution for data access amongvarious data stores and engines and types that does not suffer from manyof the problems or deficiencies associated with other solutions.

FIG. 1 illustrates an example computing environment 100 for federationof data queries across one or more computing systems. More specifically,the computing environment 100 includes a computing system 110 and datasystems 120, 130 and 140.

In some configurations, the computing system 110 includes a federatedquery engine for executing a data query or queries across multiple datasystems for accessing different types of data stored in a database orsimilar storage scheme on a respective data system. In this manner, thefederated query engine may coordinate execution of a query across themultiple data systems. The federated query engine is described infurther detail below.

As illustrated in FIG. 1, the data systems 120, 130 and 140 are multipleautonomous data systems that respectively store data 125, data 135 anddata 145. Moreover, the data systems 120, 130 and 140 (including datastored therein) may aggregately form a federated data system thatmanages/provides federated data across the multiple data systems. Someexamples of data stored by a respective data system may include, but arenot limited to, data stored according to a relational databasemanagement system, data from an online social networking service, datastored across a distributed system (e.g., NoSQL, HADOOP), metadata, etc.Other types of data may be provided in a respective data system andstill be within the scope of the subject technology.

As illustrated in the example of FIG. 1, the computing system 110 andthe data systems 120, 130 and 140 are interconnected via a network 150.In one example, the computing system 110 utilizes an appropriate dataconnection(s) (e.g., Java Database Connectivity, Open DatabaseConnectivity, etc.) for communicating with each of the data systems.Over one or more data connections, the computing system 110 can transmitand receive data via the network 150 to and from the data systems 120,130 and 140. The network 150 can include, but is not limited to, a localnetwork, remote network, or an interconnected network of networks (e.g.,Internet). Similarly, the data systems 120, 130 and 140 may beconfigured to communicate over the network 150 with the computing system110 by using any sort of network/communications/data protocol.

Although the example shown in FIG. 1 includes a single computing system110, the computing system 110 can include a respective cluster ofservers/computers that perform a same set of functions provided by thecomputing system 110 in a distributed and/or load balanced manner. Acluster can be understood as a group of servers/computers that arelinked together to seamlessly perform the same set of functions, whichcan provide performance, reliability and availability advantages over asingle server/computer architecture. Additionally, other data systemsmay be included in the example computing environment and still be withinthe scope of the subject technology.

FIG. 2 conceptually illustrates a high level architectural layout 200 ofa system 205 that implements a federated query engine according to someconfigurations of the subject technology. The federated query engine canbe implemented for execution on one or more computing devices/systems.In particular, FIG. 2 shows a system 205 for implementing the federatedquery engine described in the computing system 110 in FIG. 1 and theprocesses in FIGS. 3 and 5. The following description of FIG. 2 maydescribe different operations in a linear fashion for the sake of notobscuring the discussion. However, it should be appreciated that any ofthe operations described in FIG. 2 may be executed in a parallel mannerand still be within the scope of the subject technology.

The system 205 includes memory, one or more processors, and one or moremodules stored in memory and configured for execution by the one or moreprocessors. As shown in FIG. 2, the system 205 includes several modulesfor providing different functionality. According to one aspect of thesubject technology, a federated query engine is provided that includesthe following components: a protocol module 215, a parser module 220, abinder module 225, an optimizer module 230, a metadata manager module235, a cost estimation module 240 and an execution engine module 245.

The protocol module 215 is configured to manage end user connections byutilizing standardized database connectivity technologies such as JAVADatabase Connectivity (JDBC) or Open Database Connectivity (ODBC), etc.In this manner, the protocol module 215 is configured to allow for avariety of connection types to be utilized. After a connection isestablished, one or more queries received from a corresponding end userare transmitted to the parser module 220 for validation. For instance,an end user connects to the federated query engine through an industrystandard protocol such as but not limited to ODBC or JDBC. The end userthen submits a query 210 using a common language such as SQL. Theprotocol module 215 extracts the text of the query 210 into a standardinternal format (e.g., a format that the federated query engine mayprocess) irrespective of the protocol used to connect to the federatedquery engine. The protocol module 215 then transfers the query 210 tothe parser module 220 for processing.

The parser module 220 is configured to validate that a syntax of thelanguage used within the received query is without syntactical erroraccording to a set of predetermined syntactical rules. After the syntaxof the query 210 is validated, the query 210 is converted into a querytree which is then transmitted to the binder module 225. By way ofexample, the parser module 220 receives the query 210 from the protocolmodule 215 and parses out the words or tokens. The parser module 220 isconfigured to check the syntax of the query 210 for correctness based onthe parsed words or tokens. If the syntax of the query 210 is correct,the parser module 220 converts the query 210 into a query tree. Examplesof a query tree are described in more detail with respect to FIG. 4Abelow. The parser module 220 is configured to then identify each dataelement referenced in the query tree. An example of a data element maybe a table stored on a particular data system or similar source of data.The parser module 220 then transmits the query tree to the binder module225.

The binder module 225 receives the query tree from the parser module220. The binder module 225 is configured to access the metadata managermodule 235 to lookup each data element referenced by the query tree toadd associated metadata. For instance, the binder module 225 contactsthe metadata manager module 235 for each data element referenced in thequery to bind associated metadata to each data element. After allassociated metadata is bound to corresponding data elements referencedwithin the query tree, the binder module 225 transmits the query tree tothe optimizer module 230.

The metadata manager module 235 is configured to bind to the dataelement any known metadata about that element. Such metadata may includea number of rows, row size, and/or data types. The metadata managermodule 235 is configured to contact an appropriate persistent data storefor that such metadata. In one example, the persistent data store isidentified by the naming convention of the data element, which containsan identifiable reference to the data element location. For instance,the metadata manager module 235 contacts an appropriate metadata storefor the data element being processed. The metadata manager module 235 isconfigured to utilize any required communication mechanisms for thevarious metadata stores. In this manner, any metadata synchronizationissues between the federated query engine and the data stored on themetadata stores are minimized.

In one example, the metadata stores respectively correspond to a datasystem registered with the federated query engine. In particular, ametadata store may store metadata for unstructured data elements whenthe system 205 does not carry enough metadata. In one example, themetadata for unstructured data elements is stored within a relationaldatabase that allows the metadata to be controlled/modified by thesystem 205. In instances in which other entities are able to modify themetadata in a given metadata store, the metadata manager module 235 isconfigured to perform a “lookup” of the metadata in that metadata store.Thus, the metadata manager module 235 does not necessarily store anypersistent metadata, and instead performs lookups as required (e.g.,when other entities may modify the metadata and the system 205 does notcontrol the metadata). Any matching metadata for a given data elementfrom the query tree is then returned to the binder module 225 for thatdata element.

After the metadata manager module 235 returns metadata to the bindermodule 225, the binder module 225 determines an output data size of abottommost node in the query tree and then the above nodes are able tocalculate an estimate of an output data size for each of the abovenodes. This is done because a shape of a query plan may change as alogical exploration continues up through the query tree. The bindermodule 225 is configured to then transmit the query tree augmented withmetadata and the data size estimates to the optimizer module 230 forprocessing.

The optimizer module 230 is configured to initially process a logicalrepresentation of the query tree, and then determine any alternativephysical plans. Examples of these operations are described in furtherdetail in FIGS. 3 and 5. For instance, the optimizer module 230 makesthe best choice on how to execute the query given multiple possibilitiesbased on the logical and physical plans. In one example, the optimizermodule 230 is configured to determine an estimated cost to each possibleexecution plan for each required operation or group of operations andthen select the best overall execution plan based on the estimated cost.As described in further detail below, the estimated cost may be based ona historical record of completed queries, business rules, actual dynamicruntime loading metrics and/or other data or metrics.

Costs may be initially seeded with initial predetermined values (e.g.,based on one or more operations for small, medium, or large systems) foreach data system, and each subsequently executed operation may bestatistically incorporated into the initial predetermined values as partof the historical record for determining an estimated cost. In oneexample, the estimated cost in the historical record is allowed togradually drift based on a weighted average between a current value fora recently executed query and an existing value (e.g., based on theinitial predetermined cost). The aforementioned estimated cost may bederived through utilizing the cost estimation module 240. As anadditional alternative implementation, the cost estimation module 240processes each operation or groups of operations, and queries eachfunctionally capable data engine provided by a corresponding data systemto determine an estimated cost in some configurations. The estimatedcost may be based on latency for the data system, cost per row, cost peroperation in the query, etc. Actual dynamic runtime loading metrics mayalso be utilized to determine the estimated cost. With respect tobusiness rules, the cost estimation module 240 may remove some optionsaccording to one or more business rules that specify time of dayconstraints, security concerns, etc. Additionally, the cost estimationmodule 240 is configured to normalize the costs across multiple datasystems to present a normalized cost value to the optimizer module 230.The optimizer module 230 is configured to then select the overall bestexecution plan based on the corresponding estimated cost (nownormalized). The selected execution plan for the query is thentransmitted to the execution engine module 245 for execution.

The execution engine module 245 receives the selected execution plan forexecution of the query (as represented in the query tree) and begins toperform the necessary execution by generating proper syntax for thecorresponding data system and requesting the engine to execute anoperation or set of operations from the query. In one example, toexecute the plan, the execution engine module 245 uses appropriatedrivers or connection methods to connect to each data system andtransfers the proper syntax across the proper protocols. The executionengine module 245 also executes any required data movement operations tomove data from one data system to another through appropriate protocolsand commands.

Once that operation or set of operations is complete, the executionengine module 245 may persist any data resulting from the operation(s)and then retrieve further metadata about the operation and results. Theexecution engine module 245 then sends any updated metadata informationback to the optimizer module 230 and requests a re-optimization giventhe results of the operation(s). The re-optimization may result in achanged plan of execution for the remainder of the operations from theexecution plan that have not yet executed. The execution engine module245 then receives a plan with the lowest cost from the optimizer module230 and performs another operation from the query. These aforementionedsteps of re-optimization may be repeatedly performed for each of theremaining operations in the query. However, in some instances,re-optimization is not performed.

Once the query is entirely executed, the execution engine module 245 isconfigured to then transmit results 247 of the query back to theprotocol module 215 for transmitting to the end user. When the entireexecution plan has been executed, the results 247 from the executionengine module 245 are transmitted to the protocol module 215. Theprotocol module 215 is configured to format the results 247 and submitthe results 247 to the end user using the appropriate protocols.

Additionally, in some configurations, the metadata manager module 235 iscontacted by the execution engine module 245 to record new values foractual execution time, sizes, etc., into the metadata about a given datasystem. In this manner, the system 205 builds a historical record peroperation executed to refine the data over time and allow for moreaccurate estimations in the future. These data values can be specific toinclude things such as the size of data processed, loading on the systemat the time, individual step operation executed, type of data, etc.

FIG. 3 conceptually illustrates an example process 300 for executingseveral operations of a query according to a cost determination of a setof execution plans for the query. The process 300 can be performed byone or more computing devices or systems in some configurations. Morespecifically, the process 300 describes steps that are performed by theaforementioned federated query engine for executing a query in oneexample. Although the example process 300 illustrated in FIG. 3 shows alinear execution of operations, it should be appreciated that any of theoperations in FIG. 3 may be executed in a parallel manner and still bewithin the scope of the subject technology.

The process 300 begins at 305 by receiving a query for data storedacross a multiple data systems. The data stored across the multiple datasystems may include federated data in some implementations.

At 310, the process 300 generates logical plans for executing the queryand respective physical plans for executing each of the logical plans.In some configurations, each logical plan includes a sequence of one ormore operations for executing the query. In one example, each logicalplan comprises a query tree including one or more nodes, each noderepresenting a respective operation in the sequence of one or moreoperations for executing the query. Each node of the query tree eitherhas an expected data size or is capable of calculating the data sizethrough recursive algorithms. Thus, rather than include an estimatedoutput data size for all of the nodes in the query tree, it is morebeneficial to recursively calculate a size estimate at any stage for anyof the above nodes in the query tree. Further, as mentioned above, theprocess 300 at 305 generates respective physical plans for executing thequery on the data systems for each of the logical plans. Each physicalplan represents a set of operations that describe corresponding physicalsteps for executing the operations. For instance, a respective physicalplan may describe permutations for physically moving data from one datasystem to another data system for performing one or more operations fromthe query. Moreover, some configurations provide that an available datasystem, which does not initially include any of the required data fromthe query, may be included in a respective physical plan. Thus, arespective physical plan need not be limited to the actual data systemswhich initially include the required data from the query, and anyavailable data system may be included for a given physical plan forperforming an operation(s) from the query.

The process 300 at 315 then determines an execution cost for eachphysical plan from the respective physical plans. In someconfigurations, the process 300 looks at costs associated with latency,cost per row, movement costs, and/or cost per operation in order todetermine the execution cost for each physical plan. In one example, thecosts may be determined when applied to the aforementioned sizeestimates and/or based on additional metadata associated with a givendata system. For instance, the metadata may be based on a historicalrecord of costs for performing respective operations of previouslyexecuted operations, which in turn may be normalized across differentdata systems. Initially, each data system may be seeded with initialpredetermined costs (e.g., based on one or more operations for small,medium, or large systems), and each subsequently executed operation maybe statistically incorporated into the initial predetermined costs aspart of the historical record for determining an estimated cost. In oneexample, the estimated cost in the historical record is allowed togradually drift based on a weighted average between a current value fora recently executed query and an existing value (e.g., based on theinitial predetermined cost). In this regard, the historical record ofcosts may be weighted more heavily toward older historical data than fornewer data.

The process 300 at 320 then selects a respective physical plan with alowest determined execution cost among the determined execution cost foreach physical plan from the respective physical plans. In this manner,the process 300 may utilize the respective physical plan that ispredicted to provide optimal performance based on execution costs.

The process 300 continues to 325 to execute the first operation from thequery tree according to the selected physical plan. The first operationmay correspond with a bottom node from the query tree.

At 330, the process 300 updates the query based on results from theexecuted first operation. In some configurations, as part of updatingthe query, the process 300 may persist data resulting from the executedfirst operation from the query. Alternatively, the process 300 may notpersist data but may continue to execute more operations from the querybefore deciding to persist the data. By way of example, the process 300may determine to persist data when no dependencies exist after aparticular operation. Further, the process 300 may determine to persistdata based on the data systems involved and the type of data movementthat is to be performed. For example, in a case where data can bestreamed between locations, such as between different data systems,persisting the data may not be needed in this case. In other cases, thedata must be prepared for movement between locations and the data ispersisted. In some configurations, movement of data betweenheterogeneous data systems will require some data to be persisted. Thepersisted data may be stored in a temporary table on a given data systemfor subsequent access in some configurations.

The process 300 at 335 1) generates logical plans for executing a newquery for a remaining set of operations from the query, and 2) generatesrespective physical plans for each of the logical plans for executingthe new query. In some configurations, generating the respectivephysical plans may be based on persisted data and/or newly availablemeta-data. In this regard, corresponding size estimates in a respectivephysical plan may be replaced with the results of the first operation(or from the results stored in the persisted data) in order to generatethe respective physical plans. At 340, the process 300 determines anexecution cost for each of the respective physical plans. Next, theprocess 300 at 345 selects a physical plan with a lowest execution costamong the respective physical plans.

The process 300 at 350 executes a second operation from the queryaccording to the selected physical plan. Alternatively, the process 300in some instances continues to execute one or more operations untilreaching a point for performing a re-optimization of logical andphysical plans based on the results of the executed operations. At 355,the process 300 updates the new query based on results of the executedsecond operation (or executed operations). The process 300 then ends. Inthis manner, the process 300 may execute the plan with the lowestexecution cost after completing each operation in the query as the plansare re-optimized to account for the results of a previous operation,which may result in a more accurate estimation of costs for the plans.

Although executing a first and second operation are described in theexample of FIG. 3, it should be understood that the process 300 repeatsthe above described steps for re-optimizing the physical plans for theremaining operations until each operation from the query is executed.The process 300 may then provide the results of the query for outputafter the query is completely executed. The process 300 then ends.

FIG. 4A conceptually illustrates example query trees for a query 405according to some configurations of the subject technology. Asillustrated, FIG. 4A includes query trees 410 and 420 which representpossible logical plans for executing the query 405 (illustrated as“Select A.id, B.name, C.state from A join B on A.id=B.id join C onB.id=C.id”). In the example shown in FIG. 4A, the query 405 includesoperations on tables A, B, and C, and tables A, B and C are respectivelystored on three different data systems 1, 2 and 3. Query trees 410 and420 may provided by the federated query engine when generating logicalplans for a given query. Query trees 410 and 420 include multiple nodesthat each represent a respective operation or set of operations from thequery 405. Although two query trees are shown in the example of FIG. 4Afor the sake of simplicity, it should be appreciated that more querytrees for other logical plans for the query 405 may be provided andstill be within the scope of the subject technology.

For each of the query trees 410 and 420 corresponding to respectivelogical plans for the query 405, the federated query engine may providea set of physical plan alternatives for executing the query 405. Asmentioned above, the query 405 includes operations on tables A, B, andC, and tables A, B and C are respectively stored on three different datasystems 1, 2 and 3. A set of physical plan alternatives for the querytrees 410 and 420 are respectively illustrated in FIGS. 4B-1, 4B-2, 4C-1and 4C-2 described below.

FIGS. 4B-1 and 4B-2 conceptually illustrate an example set ofalternative physical plans for a first query tree. FIGS. 4C-1 and 4C-2conceptually illustrate an example set of alternative physical plans fora second query tree. More specifically, FIGS. 4B-1-4B-2 and FIGS.4C-1-4C-2 illustrate a set of alternative physical plans, respectively,for the query trees 410 and 420 in FIG. 4A. For the logical plans thatare generated in FIG. 4A, the federated query engine may select one ofthe set of alternative physical plans in either FIGS. 4B-1, 4B-2, 4C-1and 4C-2 based on a calculated cost for performing a set of operationsin the alternative physical plan. In one example, the federated queryengine may then execute one or more operations in the selectedalternative physical plan and then perform re-optimization of thelogical plans and alternative physical plans based on the results of theexecuted operation(s).

A set of alternative physical plans 430, 432, 434, 436, and 438 for thequery tree 410 (that logically represents the query 405 in FIG. 4A) isshown in FIGS. 4B-1 and 4B-2. Each alternative physical plan includes aset of nodes representing operations to be performed on each of theaforementioned data systems 1, 2 or 3. The federated query engine mayexecute a particular alternative physical plan starting from a bottomnode and continuing up until reaching a root node of the alternativephysical plan. For example, to execute the alternative physical plan430, the federated query engine executes, starting at the bottom node, adata transfer operation for transferring results of an operation(“Select a.id from A”) at data system 1 over to a table T1 at datasystem 2. The federated query engine then performs operations in themiddle node of the alternative physical plan 430 including a datatransfer operation for transferring results of an operation (“selectT1.id, B.name, B.id as bid from T1 join B on T1.id=B.id”) at data system2 over to table T2 at data system 3. The federated query engine maycontinue to the top node of the alternative physical plan 430 to executean operation (“select T2.id, T2.name, C.state FROM T2.join C onT2.bid=C.id”) at data system 3. The federated query engine may returnthe results of this operation to the user. In a case in which thefederated query engine selects one of the other alternative physicalplans 432, 434, 436, and 438 for executing the query 405, the selectedplan among the alternative physical plans 432, 434, 436, and 438 may beexecuted by the federated query engine in a similar manner (e.g.,starting from the bottom node and continuing up until reaching the topnode).

Each of the alternative physical plans 430, 432, 434, 436, and 438 ofFIGS. 4B-1 and 4B-2 include an estimated cost for executing thecorresponding alternative physical plan. In one example, an estimatedcost of a corresponding alternative physical plan may represent aruntime cost for executing a query according to the correspondingalternative physical plan and may be based a number of I/O operationsrequired for executing operations within the query, an estimated amountof time for executing the operations, processing/CPU requirements,expected utilization of network resources, estimated data transfertimes, and other factors, etc. In the example of FIGS. 4B-1 and 4B-2,the alternative physical plan 432 has the lowest estimated cost (e.g.,620) among the set of alternative physical plans 430, 432, 434, 436, and438. In the example of FIGS. 4C-1 and 4C-2, a set of alternativephysical plans 440, 442, 444, 446, and 448 are shown. The alternativephysical plan 440 has the lowest estimated cost (e.g., 190) among theset of alternative physical plans 440, 442, 444, 446, and 448. Thus, thealternative physical plan 440 has the lowest overall estimated costamong all of the alternative physical plans shown in FIGS. 4B-1, 4B-2,4C-1 and 4C-2. In one example, the federated query engine selects thealternative physical plan 440 as the alternative physical plan with thelowest overall cost and executes one or more operations from thealternative physical plan 440 by starting from the bottom node andcontinuing up to the top node similar to the example described above.The federated query engine may return the results of the query afterperforming the operations in the top node of the alternative physicalplan 440.

In some configurations, the federated query engine may not execute allof the operations for the nodes for a given alternative physical plansuch as the selected physical plan 440. For instance, a marker forre-optimization may be included at the middle node of the alternativephysical plan 440. The federated query engine may execute the operationsfor the bottom node, persist the results of the bottom node, and thenperform re-optimization of logical and physical plans for a remainingset of operations for the query 405 in order to provide a new set oflogical and physical plans for the remaining set of operations of thequery 405. A subsequent re-optimization of logical and physical plansfor other remaining operations of the query 405 may be performed in asimilar manner.

FIG. 5 conceptually illustrates a process 500 representing the logicinside the aforementioned optimizer module 230 described in FIG. 2above. In some configurations, the process 500 may be implemented by oneor more computing devices or systems. Although the example process 500illustrated in FIG. 5 shows a linear execution of operations, it shouldbe appreciated that any of the operations in FIG. 5 may be executed in aparallel manner and still be within the scope of the subject technology.

The process 500 begins at 502 by receiving a query for data storedacross multiple data systems. At 505, the process 500 generates one ormore logical representations of a query tree for the query. In someconfigurations, the logical representations constitute logical plans forexecuting the query. The process 500 identifies the logical planscorresponding to the logical representations of the query tree that havethe best chance for physical execution at highest performance accordingto the capabilities of respective data systems that may execute aportion of the query. The logical plans that do not represent expectedreasonable performance are not added into the list of plans that areretained.

Next, the process 500 starts working on the physical execution plan. Thefollowing steps are performed for each logical plan that was generatedat 505. To create a physical execution plan, the process 500 at 510starts evaluating at the bottom of the logical plan, which is the sourcedata (e.g., a table) in one example.

At 515, the process 500 builds physical plan alternatives for eachlogical plan from the bottom of the logical plan where source data isread, up to the return of results to the end user. The process 500builds plan alternatives for executing the first logical operation oneach of the available data systems. In one example, available datasystems may include data systems that do not have persistent or sourcedata, which would then include the need to move data from the sourcedata system to the data system where the operator will be executed underthe plan.

Next, the process 500 at 520 computes an execution cost that representsthe cost of moving data if necessary and executing the first operationfrom the query. The costs are based on normalized cost metadata, whichrepresents the ability of the each registered data system to performthat operation on the prescribed amount of data, plus the cost of movingthe prescribed amount of data to that data system. This step is repeatedfor each of the alternative plans.

At this point the number of alternative plans could be up to the cube ofthe number of registered systems. Each plan has an overall costassociated with all execution up to the point of the currently evaluatedlogical operator. The process 500 at 525 then prunes out all but thesingle lowest cost plan per registered system. The total number ofalternative plans for execution up to the currently evaluated operatoris now reduced to no more than the number of registered systems.

The process 500 at 530 places a marker, if necessary, at a point in thephysical execution plan where re-optimization should take place.Different techniques may be utilized to determine if a marker is needed,and also at which point to place such a marker. In some instances, theprocess 500 may determine that no marker is needed at all.

At 535, the process 500 determines if more logical operatorscorresponding to remaining operations in the query exist. If so, thisseries of steps 515-530 is repeated for all logical operators up thequery tree. For each logical operator the process 500 builds allavailable plans using the remaining alternative plans from previouslyevaluated operators, costs all the alternative plans, and chooses onlythe best physical plan per registered system based on lowest cost. At540, the process 500 determines if other logical plans exist (e.g., from505) and the process 500 then repeats the steps at 510-535 until alllogical plans are processed. Once the process 500 reaches the top ofeach of the logical plans, the process 500 has computed the total costfor executing the plan with the top operator on each of the registeredsystems.

At 545, the process 500 then chooses the lowest overall execution costamong the logical plan alternatives. In one example, the process 500executes the plan tree from the bottom up. While executing the plan, theprocess 500 watches for the aforementioned re-optimization markersplaced in the plan by the process 500 at 530. At the point that theprocess 500 reaches a re-optimization marker, the execution stops at550. Alternatively, if no re-optimization markers are found, the process500 continues until completion of the plan. For each step executedcompletely, the process 500 retrieves actual real data size value (e.g.,row counts and sizes, etc.) for the resulting intermediate data resultsat 535, which may be supplied through some manner from the data systemupon completion. At 560, the process 500 replaces size estimates withreal data size values in the plan.

At 565, the process 500 determines if more operations are required toexecute in the query, and if so a dynamic re-optimization begins. Inthis instance, the process 500 sends back the data containing actualvalues from the executed portion of the query and continues to 505. At505, the process 500 generates one or more logical representations ofthe remaining operations from the query. The process 500 then repeatssteps for reevaluating the logical plans and physical plans for theremaining steps, but utilizes the actual data size values for theexecuted portion of the query in place of the original estimates. Atthis point, the remainder of the execution tree may change from theoriginal or it might remain the same. Any changes would potentiallyaffect the remainder of the tree that has not executed yet.

The process 500 again submits a chosen execution plan at 545, and theprocess 500 executes the portion of the execution plan up to the nextmarker at 550. The process 500 continues to 555-565 until the entirequery execution tree has been successfully executed. The process 500then ends.

Many of the above-described features and applications are implemented assoftware processes that are specified as a set of instructions recordedon a machine readable storage medium (also referred to as computerreadable medium). When these instructions are executed by one or moreprocessing unit(s) (e.g., one or more processors, cores of processors,or other processing units), they cause the processing unit(s) to performthe actions indicated in the instructions. Examples of machine readablemedia include, but are not limited to, CD-ROMs, flash drives, RAM chips,hard drives, EPROMs, etc. The machine readable media does not includecarrier waves and electronic signals passing wirelessly or over wiredconnections.

In this specification, the term “software” is meant to include firmwareresiding in read-only memory and/or applications stored in magneticstorage, which can be read into memory for processing by a processor.Also, in some implementations, multiple software components can beimplemented as sub-parts of a larger program while remaining distinctsoftware components. In some implementations, multiple software subjectcomponents can also be implemented as separate programs. Finally, acombination of separate programs, that together implement a softwarecomponent(s) described here is within the scope of the subjecttechnology. In some implementations, the software programs, wheninstalled to operate on one or more systems, define one or more specificmachine implementations that execute and perform the operations of thesoftware programs.

A computer program (also known as a program, software, softwareapplication, script, or code) can be written in a form of programminglanguage, including compiled or interpreted languages, declarative orprocedural languages, and it can be deployed in some form, including asa stand alone program or as a module, component, subroutine, object, orother unit suitable for use in a computing environment. A computerprogram may, but need not, correspond to a file in a file system. Aprogram can be stored in a portion of a file that holds other programsor data (e.g., one or more scripts stored in a markup languagedocument), in a single file dedicated to the program in question, or inmultiple coordinated files (e.g., files that store one or more modules,sub programs, or portions of code). A computer program can be deployedto be executed on one computer or on multiple computers that are locatedat one site or distributed across multiple sites and interconnected by acommunication network.

Some configurations are implemented as software processes that includeone or more application programming interfaces (APIs) in an environmentwith calling program code interacting with other program code beingcalled through the one or more interfaces. Various function calls,messages or other types of invocations, which can include various kindsof parameters, can be transferred via the APIs between the callingprogram and the code being called. In addition, an API can provide thecalling program code the ability to use data types or classes defined inthe API and implemented in the called program code.

The following description describes an example system in which aspectsof the subject technology can be implemented.

FIG. 6 conceptually illustrates a system 600 with which someimplementations of the subject technology can be implemented. The system600 can be a computer, phone, PDA, or another sort of electronic device.Such a system includes various types of computer readable media andinterfaces for various other types of computer readable media. Thesystem 600 includes a bus 605, processing unit(s) 610, a system memory615, a read-only memory 620, a storage device 625, an optional inputinterface 630, an optional output interface 635, and a network interface640.

The bus 605 collectively represents all system, peripheral, and chipsetbuses that communicatively connect the numerous internal devices of thesystem 600. For instance, the bus 605 communicatively connects theprocessing unit(s) 610 with the read-only memory 620, the system memory615, and the storage device 625.

From these various memory units, the processing unit(s) 610 retrievesinstructions to execute and data to process in order to execute theprocesses of the subject technology. The processing unit(s) can be asingle processor or a multi-core processor in different implementations.

The read-only-memory (ROM) 620 stores static data and instructions thatare needed by the processing unit(s) 610 and other modules of the system600. The storage device 625, on the other hand, is a read-and-writememory device. This device is a non-volatile memory unit that storesinstructions and data even when the system 600 is off. Someimplementations of the subject technology use a mass-storage device(such as a magnetic or optical disk and its corresponding disk drive) asthe storage device 625.

Other implementations use a removable storage device (such as a flashdrive, a floppy disk, and its corresponding disk drive) as the storagedevice 625. Like the storage device 625, the system memory 615 is aread-and-write memory device. However, unlike storage device 625, thesystem memory 615 is a volatile read-and-write memory, such a randomaccess memory. The system memory 615 stores some of the instructions anddata that the processor needs at runtime. In some implementations, thesubject technology's processes are stored in the system memory 615, thestorage device 625, and/or the read-only memory 620. For example, thevarious memory units include instructions for processing multimediaitems in accordance with some implementations. From these various memoryunits, the processing unit(s) 610 retrieves instructions to execute anddata to process in order to execute the processes of someimplementations.

The bus 605 also connects to the optional input and output interfaces630 and 635. The optional input interface 630 enables the user tocommunicate information and select commands to the system. The optionalinput interface 630 can interface with alphanumeric keyboards andpointing devices (also called “cursor control devices”). The optionaloutput interface 635 can provide display images generated by the system600. The optional output interface 635 can interface with printers anddisplay devices, such as cathode ray tubes (CRT) or liquid crystaldisplays (LCD). Some implementations can interface with devices such asa touchscreen that functions as both input and output devices.

Finally, as shown in FIG. 6, bus 605 also couples system 600 to anetwork interface 640 through a network adapter (not shown). In thismanner, the computer can be a part of a network of computers (such as alocal area network (“LAN”), a wide area network (“WAN”), or an Intranet,or an interconnected network of networks, such as the Internet. Thecomponents of system 600 can be used in conjunction with the subjecttechnology.

These functions described above can be implemented in digital electroniccircuitry, in computer software, firmware or hardware. The techniquescan be implemented using one or more computer program products.Programmable processors and computers can be included in or packaged asmobile devices. The processes and logic flows can be performed by one ormore programmable processors and by one or more programmable logiccircuitry. General and special purpose computing devices and storagedevices can be interconnected through communication networks.

Some implementations include electronic components, such asmicroprocessors, storage and memory that store computer programinstructions in a machine-readable or computer-readable medium(alternatively referred to as computer-readable storage media,machine-readable media, or machine-readable storage media). Someexamples of such computer-readable media include RAM, ROM, read-onlycompact discs (CD-ROM), recordable compact discs (CD-R), rewritablecompact discs (CD-RW), read-only digital versatile discs (e.g., DVD-ROM,dual-layer DVD-ROM), a variety of recordable/rewritable DVDs (e.g.,DVD-RAM, DVD-RW, DVD+RW, etc.), flash memory (e.g., SD cards, mini-SDcards, micro-SD cards, etc.), magnetic and/or solid state hard drives,read-only and recordable Blu-Ray® discs, ultra density optical discs,optical or magnetic media, and floppy disks. The computer-readable mediacan store a computer program that is executable by at least oneprocessing unit and includes sets of instructions for performing variousoperations. Examples of computer programs or computer code includemachine code, such as is produced by a compiler, and files includinghigher-level code that are executed by a computer, an electroniccomponent, or a microprocessor using an interpreter.

While the above discussion primarily refers to microprocessor ormulti-core processors that execute software, some implementations areperformed by one or more integrated circuits, such as applicationspecific integrated circuits (ASICs) or field programmable gate arrays(FPGAs). In some implementations, such integrated circuits executeinstructions that are stored on the circuit itself.

As used in this specification and the claims of this application, theterms “computer”, “server”, “processor”, and “memory” all refer toelectronic or other technological devices. These terms exclude people orgroups of people. For the purposes of the specification, the termsdisplay or displaying means displaying on an electronic device. As usedin this specification and the claims of this application, the terms“computer readable medium” and “computer readable media” are entirelyrestricted to tangible, physical objects that store information in aform that is readable by a computer. These terms exclude wirelesssignals, wired download signals, and other ephemeral signals.

To provide for interaction with a user, implementations of the subjectmatter described in this specification can be implemented on a computerhaving a display device, e.g., a CRT (cathode ray tube) or LCD (liquidcrystal display) monitor, for displaying information to the user and akeyboard and a pointing device, e.g., a mouse or a trackball, by whichthe user can provide input to the computer. Other kinds of devices canbe used to provide for interaction with a user as well; for example,feedback provided to the user can be a form of sensory feedback, e.g.,visual feedback, auditory feedback, or tactile feedback; and input fromthe user can be received in a form, including acoustic, speech, ortactile input. In addition, a computer can interact with a user bysending documents to and receiving documents from a device that is usedby the user; for example, by sending web pages to a web browser on auser's client device in response to requests received from the webbrowser.

Configurations of the subject matter described in this specification canbe implemented in a computing system that includes a back end component,e.g., as a data server, or that includes a middleware component, e.g.,an application server, or that includes a front end component, e.g., aclient computer having a graphical user interface or a Web browserthrough which a user can interact with an implementation of the subjectmatter described in this specification, or a combination of one or moresuch back end, middleware, or front end components. The components ofthe system can be interconnected by a form or medium of digital datacommunication, e.g., a communication network. Examples of communicationnetworks include a local area network (“LAN”) and a wide area network(“WAN”), an inter-network (e.g., the Internet), and peer-to-peernetworks (e.g., ad hoc peer-to-peer networks).

The computing system can include clients and servers. A client andserver are generally remote from each other and typically interactthrough a communication network. The relationship of client and serverarises by virtue of computer programs running on the respectivecomputers and having a client-server relationship to each other. In someconfigurations, a server transmits data (e.g., an HTML page) to a clientdevice (e.g., for purposes of displaying data to and receiving userinput from a user interacting with the client device). Data generated atthe client device (e.g., a result of the user interaction) can bereceived from the client device at the server.

It is understood that a specific order or hierarchy of steps in theprocesses disclosed is an illustration of example approaches. Based upondesign preferences, it is understood that the specific order orhierarchy of steps in the processes can be rearranged, or that allillustrated steps be performed. Some of the steps can be performedsimultaneously. For example, in certain circumstances, multitasking andparallel processing can be advantageous. Moreover, the separation ofvarious system components in the configurations described above shouldnot be understood as requiring such separation in all configurations,and it should be understood that the described program components andsystems can generally be integrated together in a single softwareproduct or packaged into multiple software products.

The previous description is provided to enable a person skilled in theart to practice the various aspects described herein. Variousmodifications to these aspects will be readily apparent to those skilledin the art, and the generic principles defined herein can be applied toother aspects. Thus, the claims are not intended to be limited to theaspects shown herein, but is to be accorded the full scope consistentwith the language claims, wherein reference to an element in thesingular is not intended to mean “one and only one” unless specificallyso stated, but rather “one or more.” Unless specifically statedotherwise, the term “some” refers to one or more. Pronouns in themasculine (e.g., his) include the feminine and neuter gender (e.g., herand its) and vice versa. Headings and subheadings, if any, are used forconvenience only and do not limit the subject technology.

A phrase such as an “aspect” does not imply that such aspect isessential to the subject technology or that such aspect applies to allconfigurations of the subject technology. A disclosure relating to anaspect can apply to all configurations, or one or more configurations. Aphrase such as an aspect can refer to one or more aspects and viceversa. A phrase such as a “configuration” does not imply that suchconfiguration is essential to the subject technology or that suchconfiguration applies to all configurations of the subject technology. Adisclosure relating to a configuration can apply to all configurations,or one or more configurations. A phrase such as a configuration canrefer to one or more configurations and vice versa.

What is claimed is:
 1. A machine-implemented method, the methodcomprising: receiving a query for data stored across a plurality of datasystems; generating a plurality of first logical plans for executing thequery; for each of the plurality of first logical plans: generating afirst set of physical plans for executing the query on the plurality ofdata systems based on the respective first logical plan; determining anexecution cost for each physical plan from the first set of physicalplans; and selecting the physical plan with a lowest determinedexecution cost from the first set of physical plans; selecting aphysical plan with a lowest execution cost from among the respectivephysical plans selected for each of the plurality of first logicalplans; executing an operation from the query according to the physicalplan selected from among the respective physical plans selected for eachof the plurality of first logical plans; updating the query based onresults from the executed operation; generating a plurality of secondlogical plans for executing the updated query and a respective secondset of physical plans for each of the plurality of second logical plans;determining an execution cost for each physical plan from the respectivesecond sets of physical plans for the plurality of second logical plans;selecting a physical plan with a lowest determined execution cost amongthe respective second sets of physical plans for the plurality of secondlogical plans; executing an operation from the updated query accordingto the physical plan selected from among the respective second sets ofphysical plans; updating the updated query based on results from theexecuted operation from the updated query; and repeating the steps forgenerating a plurality of second logical plans and respective secondsets of physical plans, determining an execution cost for each physicalplan from the second sets of physical plans, selecting a physical planwith a lowest determined execution cost among the second sets ofphysical plans, executing an operation from the updated query, andupdating the updated query until the updated query is complete.
 2. Themethod of claim 1, wherein updating the query based on results from theexecuted operation from the query further comprises: persisting databased on results from the executed operation.
 3. The method of claim 2,wherein the persisted data is utilized to replace size estimates withreal data values in the respective physical plans for each of theplurality of second logical plans.
 4. The method of claim 1, whereineach logical plan comprises a sequence of one or more operations forexecuting the query.
 5. The method of claim 4, wherein each logical plancomprises a query tree including one or more nodes, each noderepresenting a respective operation in the sequence of one or moreoperations for executing the query.
 6. The method of claim 5, whereinthe first operation corresponds with a bottom node from the query tree.7. The method of claim 1, wherein selecting a physical plan with alowest execution cost among the selected respective physical plans ofeach of the logical plans comprises: selecting the physical plan with alowest execution cost for the first operation among the selectedrespective physical plans.
 8. The method of claim 1, further comprising:persisting data resulting from the executed operation from the updatedquery; generating a set of optimized physical plans for executing aremaining set of operations from the updated query based on thepersisted data; selecting a physical plan with a lowest execution costamong the optimized physical plans; and executing an operation from theupdated query according to the selected physical plan.
 9. The method ofclaim 1, wherein determining the execution cost for each physical planfrom the first set of physical plans is based on a historical record ofpreviously executed operations.
 10. The method of claim 1, wherein theexecution cost includes at least one of a latency cost, a cost per row,and a cost corresponding to a respective operation.
 11. The method ofclaim 1, wherein the data stored across a plurality of data systemscomprises federated data.
 12. The method of claim 1, wherein determiningthe execution cost for each physical plan from the first set of physicalplans is based on a set of business rules.
 13. The method of claim 1,further comprising: providing results of the executed operation from theupdated query for output.
 14. A system, the system comprising: memory;one or more processors; one or more modules stored in memory andconfigured for execution by the one or more processors, the modulescomprising: a protocol module configured to receive a query; a parsermodule configured to receive the query from the protocol module,validate a syntax of the received query, convert the query into a querytree if the syntax is validated, and identify each data elementreferenced in the query tree; a binder module configured to add metadatafor each data element referenced by the query tree; an optimizer moduleconfigured to determine one or more physical execution plans based onthe query tree, estimate a cost for each of the physical execution plansbased on the metadata for each data element referenced by the querytree, and select a respective physical execution plan with an overalllowest estimated cost; and an execution engine module configured toexecute an operation from the query based on the selected respectivephysical execution plan, and persist data resulting from the executedoperation from the query, wherein the optimizer module is furtherconfigured to re-determine one or more physical execution plans based onthe query tree updated with the data resulting from the executedoperation, estimate a cost for each of the re-determined one or morephysical execution plans based on metadata for each data elementreferenced by the updated query tree, and select a physical executionplan with an overall lowest estimated cost from the re-determined one ormore physical execution plans, wherein the execution engine module isfurther configured to execute an operation from the updated query treebased on the physical execution plan selected from the re-determined oneor more physical execution plans, and persist data resulting from theexecuted operation from the updated query tree, and wherein theoptimizer module is further configured to repeat the re-determining andcost estimating steps, and the execution engine is further configured torepeat the executing an operation from the updated query tree step andthe persisting data from the operation step until execution of theupdated query tree is complete.
 15. The system of claim 14, wherein thebinder module adds metadata for each data element referenced by thequery tree by utilizing a metadata manager module.
 16. The system ofclaim 14, wherein the metadata manager module is further configured toretrieve metadata about results of the operation, and send the retrievedmetadata information to the optimizer module for re-optimization of thephysical execution plans.
 17. The system of claim 14, wherein themetadata manager module is configured to: bind to each data elementassociated metadata, wherein the associated metadata includes a numberof rows, row size, or data types.
 18. The system of claim 14, whereinthe associated metadata is stored in persistent data store correspondingto a data system for each data element.
 19. The system of claim 14,wherein the optimizer module is further configured to estimate the costfor each of the physical execution plans by querying a cost estimationmodule.
 20. The system of claim 14, further comprising: a costestimation module configured to query a data system to determine anestimated cost for the operation.
 21. The system of claim 20, whereinthe estimated cost is based on latency for the data system, cost perrow, or a cost per operation in the query.
 22. The system of claim 20,wherein the cost estimation module is further configured to: normalizethe estimated cost across one or more data systems.
 23. A non-transitorymachine-readable medium comprising instructions stored therein, whichwhen executed by a machine, cause the machine to perform operationscomprising: receiving a query for data stored across a plurality of datasystems; generating a plurality of first logical plans for executing thequery and a respective first set of physical plans for executing each ofthe plurality of first logical plans on the plurality of data systems;determining an execution cost for each physical plan of the first setsof physical plans; selecting a physical plan with a lowest determinedexecution cost from among the first sets of physical plans; executing anoperation from the query according to the physical plan selected fromamong the first sets of physical plans; updating the query based onresults from the executed operation; generating a plurality of secondlogical plans for executing the updated query and a respective secondset of physical plans for executing each of the plurality of secondlogical plans on the plurality of data systems; determining an executioncost for each physical plan of the second sets of physical plans;selecting a physical plan with a lowest determined execution cost fromamong the second sets of physical plans; executing an operation from theupdated query according to the physical plan selected from among thesecond sets of physical plans; updating the updated query based onresults from the executed operation from the updated query; andrepeating the operations for generating a plurality of second logicalplans and respective second sets of physical plans, determining anexecution cost for each physical plan from the second sets of physicalplans, selecting a physical plan with a lowest determined execution costamong the second sets of physical plans, executing an operation from theupdated query, and updating the updated query until the updated query iscomplete.
 24. The non-transitory machine-readable medium of claim 23,comprising further instructions stored therein, which when executed bythe machine, cause the machine to perform further operations comprising:providing results of the completed query for output.
 25. Thenon-transitory machine-readable medium of claim 23, comprising furtherinstructions stored therein, which when executed by the machine, causethe machine to perform further operations comprising: persisting theresults from the executed operation.